package cn.mi.mishop.user.controller;

import cn.mi.mishop.base.response.JsonResult;
import cn.mi.mishop.user.pojo.dto.UserDto;
import cn.mi.mishop.user.pojo.dto.UserLoginDto;
import cn.mi.mishop.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/v1/register")
public class UserController {
    @Autowired
    UserService userService;

    @PostMapping("add")
    public JsonResult addUser(@RequestBody UserDto userDto) {
        userService.addUser(userDto);
        log.info("用户注册成功");
        return JsonResult.ok();
    }
    @PostMapping("login")
    public JsonResult login(@RequestBody UserLoginDto userLogin) {
        userService.login(userLogin);
        log.info("用户登录成功");
        return JsonResult.ok();
    }
}
